import Vue from 'vue'
import Vuex from 'vuex'
import { UserInfoApi, userDataApi } from '../Api/userinfo'
// import { getCommentApi } from '../Api/detail'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 用户信息
    userInfo: {},
    intor: ''
  },
  mutations: {
    getUserInfo (state, data) {
      state.userInfo = data
    },
    getIntro (state, data) {
      state.intor = data
    }
    // gethuifuPinglun (state,data){
    //   state.commentList=data
    // }
  },
  actions: {
    // 更新用户信息请求
    async getUserInfo (context) {
      const res = await UserInfoApi()
      context.commit('getUserInfo', res.data.data)
    },
    // 更新用户数据信息
    async getIntro (context) {
      const res = await userDataApi()
      context.commit('getIntro', res.data.data.intro)
    }
    // async getPinglunApi(context){
    //   const res =await getCommentApi(obj)
    //   context.commit('gethuifuPinglun',res.data.data.results)
    // }
  },
  modules: {}
})
